tableRetMeanSd <- function(returnslist, periods=c(2,5,10,20), latex=FALSE, market="", trendfilter="") {
  if('package:xtable' %in% search() || require('xtable',quietly=TRUE)) {}
  # build frame of data.frame
  dflength <- length(returnslist)
  df <- data.frame(pattern=character(dflength), stringsAsFactors = FALSE)
  dfdayn <- data.frame(Mean=numeric(dflength), Sd=numeric(dflength))
  dfnobs <- data.frame(Obs=numeric(dflength))
  for (i in 1:length(periods)) {
    df <- cbind(df, dfdayn)
  }
  df <- cbind(df, dfnobs)
  
  # fill the frame with values
  for (i in 1:length(returnslist)) {
    df[i,1] <- names(returnslist)[i]
    cmean<-colMeans(returnslist[[i]], na.rm=TRUE)*100
    csd<-colSd(returnslist[[i]], na.rm=TRUE)*100
    thispatterndflist <- list()
    for (j in 1:length(periods)) {
      df[i,j*2] <- cmean[periods[j]]
      df[i,j*2+1] <- csd[periods[j]]      
    }
    df[i,length(periods)*2+2] <- dim(returnslist[[i]])[1]
  }
  if (latex==TRUE) {
    title <- sprintf("Arithmetisches Mittel und Standardabweichung 
    der Renditen nach n=(2,5,10,20) Tagen nach Auftreten des Kursmusters. 
    Datensatz: %s; Trendfilterung: %s", market, trendfilter)
    label <- sprintf("tab:returns:%s:%s", market, trendfilter)
    xt <- xtable(df,
                 caption=title,
                 label=label,
                 align="c|r|cc|cc|cc|cc|r|",
                 display=c("s","s", "f","f", "f","f", "f","f", "f","f", "d"))
    print(xt, include.rownames=FALSE)
  } else {
    return(df)
  }
}